﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Ccr.Core;

namespace XcoAppSpaces.Discovery
{
	public class PDiscoveryWorker : PortSet<RegisterSpace, UnRegisterSpace, DiscoveryRequest>
	{
	}

	[Serializable]
	public class DiscoveryRequest
	{
		public Type WorkerType { get; set; }
		public string WorkerName { get; set; }
		//public string LocalSpaceAddress { get; set; }
		public Port<DiscoveryResponse> ResponsePort { get; set; }
	}

	[Serializable]
	public class DiscoveryResponse
	{
		public DiscoveryResult Result { get; set; }
		public string WorkerAddress { get; set; }
	}

	[Serializable]
	public class RegisterSpace
	{
		public string SpaceAddress { get; set; }
		public Port<DiscoveryRequest> DiscoveryPort { get; set; }
	}

	[Serializable]
	public class UnRegisterSpace
	{
		public string SpaceAddress { get; set; }
	}

	public enum DiscoveryResult
	{
		WorkerFoundRemote,
		WorkerFoundLocal,
		WorkerNotFound
	}
}
